<%@ page import="java.net.URLEncoder" %><%--
  Created by IntelliJ IDEA.
  User: 范军建
  Date: 2022/3/28
  Time: 18:44
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
</head>
<body>

<%
    request.setCharacterEncoding("utf-8");
    String userName = request.getParameter("userName");
    String password = request.getParameter("password");
    if (userName.equals("admin") && password.equals("123456")) {
        Cookie mycook=new Cookie("userInfo",userName+"#"+password);  //设置cookie对象
        /*mycook.setMaxAge(60*60*20*365); //设置cookie有效期*/
        response.addCookie(mycook);//把cookie对象发送到客户端进行存储
        response.sendRedirect(request.getContextPath() + "/longin.jsp");
    }else {
        request.setAttribute("num1","注册失败");
        request.getRequestDispatcher("file.jsp").forward(request,response);
    }
%>



</body>
</html>
